﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class mapoffset_offset : System.Web.UI.Page
{
    Dictionary<int, int> dics = new Dictionary<int, int>();
    List<coor> coors = null;
    protected void Page_Load(object sender, EventArgs e)
    {
        //System.IO.Stream stream = new System.IO.MemoryMappedFiles;
        //System.IO.Compression.DeflateStream defalate = new System.IO.Compression.DeflateStream()

        //输入文件，即下载后解压后的文件   
        System.IO.FileStream fs1 = new System.IO.FileStream(Server.MapPath("./offset.xMap"), System.IO.FileMode.OpenOrCreate);
        System.IO.BinaryReader sr = new System.IO.BinaryReader(fs1);
        long records = fs1.Length / 8;
        int cont = 0;
        coors = new List<coor>((int)records);


        cor max = null;
        cor min = null;

        byte[] data;
        while (records-- > 0)
        {

            short longitude = sr.ReadInt16();
            short lat = sr.ReadInt16();
            if(min==null)
            {
                min = new cor() { lat=lat, lon=longitude};
                max = new cor() { lat = lat, lon = longitude };
            }

            max.lat = Math.Max(max.lat, lat);
            max.lon = Math.Max(max.lon, longitude);

            min.lat = Math.Min(min.lat, lat);
            min.lon = Math.Min(min.lon, longitude);


            short x = sr.ReadInt16();
            short y = sr.ReadInt16();
            data = sr.ReadBytes(8);
            dics.Add(BitConverter.ToInt32(data, 0), cont); //占用300MB内存
            //coors.Add(new coor() {key = BitConverter.ToInt32(data, 0), val = cont});
            cont += 8;
            data = null;
        }


        sr.Close();
        fs1.Close();
        sr.Dispose();
        fs1.Dispose();

        //循环个数
    var maxout=     (max.lat - min.lat)*(max.lon - min.lon);

    }

    /// <summary>
    /// 坐标
    /// </summary>
    public class cor
    {
        public short lon;
        public short lat;
    }

    public struct coor
    {
        public int key;
        public int val;
    }
}